<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>4-组件事件传递高级用法</title>
		<script src="../vue@3.2.23.js"></script>
	</head>
	<body>
		<div id="app">
			<counter v-model:count="count"></counter>
			<input type="text"  v-model="count"/>
		</div>
	</body>
</html>
<script>
	const counter = {
		props:["count"],
		methods:{
			changeCount(){
				this.$emit("updata:count",this.count + 1)
			}
		},
		template:
		`
			<div @click="changeCount">子组件计数器:{{count}}</div>
			<button @click="changeCount">修改count</button>
		`
	}
	
	const app = Vue.createApp({
		components:{counter},
		data(){
			return{
				count:10
			}
	}
	}
	)
	
	const vm = app.mount("#app")
</script>